import 'package:flutter/material.dart';
import 'package:flutter_book_store/book/book_model.dart';
import 'package:flutter_book_store/net/apis.dart';
import 'package:flutter_book_store/routes/app_pages.dart';
import 'package:get/get.dart';

class BookListPage extends GetView<BookModel> {
  List<Widget> widgets = List();

  @override
  Widget build(BuildContext context) {
    return Container(
      color: Colors.white,
      child: Padding(
        padding: const EdgeInsets.symmetric(horizontal: 8),
        child: Column(
          children: [
            SizedBox(
              height: 10,
            ),
            Container(
              padding: EdgeInsets.symmetric(horizontal: 16),
              child: TextField(
                  decoration: InputDecoration(
                    isDense: true,
                    border: InputBorder.none,
                    focusedBorder: InputBorder.none,
                    hintText: "请输入搜索关键字",
                    hintMaxLines: 1,
                    hintStyle: TextStyle(color: Colors.black38),
                    icon: Icon(
                      Icons.search,
                      color: Colors.grey,
                    ),
                  )),
              decoration: BoxDecoration(
                  color: Colors.grey.shade200,
                  borderRadius: BorderRadius.all(Radius.circular(5))),
              height: 38,
            ),
            Expanded(
              child: Padding(
                  padding: const EdgeInsets.symmetric(horizontal: 8),
                  child: Obx(() =>
                      ListView.builder(
                          itemCount: controller.datas.length,
                          itemBuilder: (context, index) {
                            final country = controller.datas[index];
                            return GestureDetector(
                              onTap: () {
                                Get.toNamed(Routes.BOOKDETAIL, arguments: controller.datas[index]);
                              },
                              child: Column(
                                children: [
                                  Container(
                                    height: 48,
                                    child: Row(
                                      mainAxisSize: MainAxisSize.max,
                                      mainAxisAlignment: MainAxisAlignment
                                          .spaceBetween,
                                      children: [
                                        Text(
                                          controller.datas[index].author,
                                          style: TextStyle(color: Colors.black,
                                              fontSize: 16),
                                        ),
                                        Icon(Icons.chevron_right)
                                      ],
                                    ),
                                  ),
                                  Container(
                                    width: double.infinity,
                                    height: 1,
                                    color: Colors.grey.shade300,
                                  )
                                ],
                              ),
                            );
                          }))),
            ),
          ],
        ),
      ),
    );
  }
}
